fix(dashboard): handle missing RealUnit price instead of crashing the price chart#695
Merged
Merged
Conversation
… chart The price endpoints omit chf/eur while a quote is unavailable: /v1/realunit/price returns just a timestamp, and the latest entry of /v1/realunit/price/history has no chf/eur. getPriceChart did BigInt.from(entry['chf'] * 100) per entry, so a single null point threw and discarded the ENTIRE price history, leaving the chart empty. getPriceOfAsset threw on the same null. - getPriceChart: skip entries whose selected-currency price is null, keeping all valued points (chart renders the full history minus the unpriced tail). - getPriceOfAsset: return zero when the price is missing so the UI shows "--.--". - getChfToEurRate: treat a missing chf/eur as 0 (no throw, already guards chf>0).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The public price view ("RealUnit Aktienkurs") shows an empty chart and
CHF --.--whenever the RealUnit quote is temporarily unavailable.Confirmed against the live API:
GET /v1/realunit/price→{"timestamp":"2026-06-04T22:28:16.539Z"}— nochf/eur.GET /v1/realunit/price/history?timeFrame=ALL→ 1514 points, 1513 valid, only the latest (2026-06-04) has nochf/eur.DFXPriceService.getPriceChartdidBigInt.from(entry['chf'] * 100)for every entry, so the single null point threw (null * 100), the whole method threw, andpriceChartstayed[]→ the entire history (1513 valid points) was discarded and the chart rendered empty.getPriceOfAssetthrew on the same null.This is the same defect class as the portfolio-chart fix in #694, but in the price code path (
dfx_price_service.dart), which #694 does not touch. It is more visible because it affects the wallet-less public price view.Fix
getPriceChart: skip entries whose selected-currency price isnullinstead of throwing — the chart renders the full history minus the unpriced tail point.getPriceOfAsset: returnBigInt.zerowhen the price is missing, so the UI renders--.--instead of throwing.getChfToEurRate: treat a missingchf/euras0(already guardschf > 0).Tests
getPriceChartskips a trailing null point and keeps earlier valued points.getPriceOfAssetreturns zero on a missing price.getChfToEurRatereturns0.0on a missing price.flutter analyzeclean; price-service + price-chart-cubit suites green (22 tests).Test plan
chf/eur→ price chart renders full history, header--.--, no empty chart.chf/eur→ header--.--, no crash.Related